package thread;

public class Demo13 {
    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(() -> {
            for (int i = 0; i < 3; i++) {
                System.out.println("t1");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        });
        Thread t2 = new Thread(() -> {
            for (int i = 0; i < 4; i++) {
                System.out.println("t2");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        });

        t1.start();
        t2.start();

        t1.join();//可以插入毫秒级时间（或者（毫秒，纳秒））
        t2.join();//这两行代码谁写在上谁写在下，效果一样，总 的等待时间都是t1和t2运行较长的时间
        System.out.println("main over");
    }
}
